package com.tzy.user.controller;
import com.tzy.user.service.WebContentService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@RestController
public class WebContentController {
    @Resource
    private WebContentService contentService;

    /**
     * 根据关键字搜索并保存到 ElasticSearch
     * @param keyword
     * @return
     * @throws Exception
     */
    @GetMapping("/parse/{keyword}")
    public Boolean parse(@PathVariable("keyword") String keyword) throws
            Exception {
        return contentService.parseContent(keyword);
    }
//    /**
//     * 根据关键字搜索
//     * Demo: http://localhost:9090/search/java/1/10
//     * @param keyword
//     * @param pageNo
//     * @param pageSize
//     * @return
//     * @throws Exception
//     */
//    @GetMapping("/search/{keyword}/{pageNo}/{pageSize}")
//    public List<Map<String, Object>> search(@PathVariable("keyword") String keyword,
//                                            @PathVariable("pageNo") int pageNo,
//                                            @PathVariable("pageSize") int pageSize) throws
//            Exception {
//        return contentService.searchContentPage(keyword, pageNo, pageSize);
//    }
}